package util;

import java.io.InputStream;
import java.util.Properties;

public class ConfPropertiesUtil {

    private static final ConfPropertiesUtil instance = new ConfPropertiesUtil();

    public static ConfPropertiesUtil getInstance() {
        return instance;
    }

    Properties properties = new Properties();

    public int _PORT;
    public String _IP;
    public String _CLIENT_TOKEN_PREFIX;
    public int _CLIENT_BEGIN_NUN;
    public int _CLIENT_NUM;
    public int _SECOND_LOGIN_NUM;
    public String _ACTION_LIST;

    public void init() {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        InputStream inStream = loader.getResourceAsStream("properties");//加载resources目录的配置文件
        try {
            properties.load(inStream);
        } catch (Exception e) {
            LogUtil.game.error("Exception", e);
            System.exit(0);
        }
        _PORT = Integer.valueOf(properties.getProperty("_PORT"));
        _IP = properties.getProperty("_IP");
        _CLIENT_TOKEN_PREFIX = properties.getProperty("_CLIENT_TOKEN_PREFIX");
        _CLIENT_BEGIN_NUN = Integer.valueOf(properties.getProperty("_CLIENT_BEGIN_NUN"));
        _CLIENT_NUM = Integer.valueOf(properties.getProperty("_CLIENT_NUM"));
        _SECOND_LOGIN_NUM = Integer.valueOf(properties.getProperty("_SECOND_LOGIN_NUM"));
        _ACTION_LIST = properties.getProperty("_ACTION_LIST");
    }
}
